package es.us.lsi.aws.api.externalservices;

import java.util.List;

import es.us.lsi.aws.api.model.Message;
import es.us.lsi.aws.api.model.SocialAccount;
import es.us.lsi.aws.api.model.TwitterSocialAccount;
import es.us.lsi.aws.api.server.dao.DAOSocialAccount;

public class UtilExternalServices {

	public static void sendMessage(Message message) {
		List<SocialAccount> lstSocialAccount = message.getLstSocialAccount();
		for (SocialAccount socialAccount : lstSocialAccount) {
			SocialAccount storedSocialAccount = DAOSocialAccount.getAccount(
					socialAccount.getName(), socialAccount.getSocialNetwork());
			if (storedSocialAccount instanceof TwitterSocialAccount) {
				TwitterHelper tHelper = new TwitterHelper(
						(TwitterSocialAccount) storedSocialAccount);

				tHelper.post(message.getText());
			}
		}
	}

}
